ASP Date Problem !

0
August 15, 2011

Hi,

I have a table with fromdate and todate.

I have set its default format as dd/mm/yyyy.

In ASP, where I use the table I have used session.lcid = 2057 (which is again dd/mm/yyyy) format

But when I use a query,

sql="select * from tblbookings b,tblstudents s where b.fldstudentid=s.fldid and fldfromdt <= #" & d1 & "# and fldfromdt <= #" & d2 & "# "

where d1 = 01/05/2008 and d2 = 31/07/2008

the code runs a loop from d1 to d2 and checks if the date falls between the from date and to date in the table it displays the record.

fldfromdt = 01/07/2008      fldtodt = 07/31/2008

right now what it is doing is while comparing making fldfromdt in table as mm/dd/yyyy, where as in the table it is dd/mm/yyyy

hope i was able to explain the question properly.

pls help me fast.

14

answers

Comments See all(0)

Add comment
0
August 15, 2011

No, no I am not saying that. Regional settings are the easiest and you do not need to make any chages.

Of course you can use lcid, dateformta etc,etc.

But remember, storing a date in a db is meaningless. Let it get stored whatever way. You should be concerned with displaying. So if you make db date strong format as the baseline, you can programmitically change to follow your format

0
August 15, 2011

The issue is that, in asp you set date format as dd/mm/yyyy but MS Access db is still having default date format as mm/dd/yyyy

better to use yyyy/mm/dd or dd/mmm/yyyy format in your queries to avoid any such ambiguity..

0
August 15, 2011

Hello Desire2change,

That is because you are using Access. (At least that is my guess). Access has this known issue, regardless of any settings you use it will always interpret dates in mm/dd/yyyy format. The only way you can work around this is to use an unambiguous date format such as yyyy-mm-dd when constructing your query statement. Some people also like to use dd mmm yyyy though this does not always work well with different languages.

Regards,

TimCottee

0
August 15, 2011

You can try something like this

<%

sql="select * from tblbookings b,tblstudents s where b.fldstudentid=s.fldid and fldfromdt <= #" & formatDate(d1) & "# and fldfromdt <= #" & formatDate(d2) & "# "

function formatDate(myDate)

if isDate(myDate) Then

myDate = Right("00" & Month(myDate),2) & "/" & Right("00" & Day(myDate),2) & "/" & Right(Year(myDate),2)

End if

formatDate = myDate

End function

%>

0
August 15, 2011

sorry.. here is updated code..

<%

sql="select * from tblbookings b,tblstudents s where b.fldstudentid=s.fldid and fldfromdt <= #" & formatDate(d1) & "# and fldfromdt <= #" & formatDate(d2) & "# "

function formatDate(myDate)

if isDate(myDate) Then

myDate = Year(myDate)  & "/" & Month(myDate) & "/" & Day(myDate)

End if

formatDate = myDate

End function

%>

0
August 15, 2011

Thanks for all the response.

ok in asp, if I want to set mm/dd/yyyy then ?

I changed session.lcid = 1033 but even then when i display date() it displays 30/06/2008 instead of 06/30/2008.

0
August 15, 2011

Are your sure this is happening ??

try this and show me the output..

<%

session.lcid = 1033

Response.Write Date()

%>

0
August 15, 2011

YES !!

I tried again with only these two statements and it is giving me

30/06/2008

0
August 15, 2011

well.. really cant say why it is happening so.. it should not be..

the work around is, use explicit formatting of data before printing.. they way i explained above..

0
August 15, 2011

Have you tried changing Regional and language options in Control panel ?

Go to Control Panel-->Regional and language options and then choose the format that best suits you from drop down or you can even create of your own

0
August 15, 2011

but I will using it at another server, so there i will not b able to change the regional settings

0
August 15, 2011

Yes, it is server based. So unless you want to make a region base server, this would by far the best solution

0
August 15, 2011

so there is no other solution.

0
August 15, 2011

thanks

Related Questions

Date problem using LINQ to SQL

I thought I had fixed my problem but it seems it is still there... I am utterly rubbish with dates when it comes to db fields etc :( I have 3 date/time fields: InChargeDate, WorkDate, WorkTime. obviou Read More

Views

26

Votes

0

Answers

14

August 15, 2011

Parameter problem when accessing Oracle stored procedure from ASP/ADO

I have an Oracle package containing a number of calendar-related functions which I need to call from ASP. However, I am receiving an error message, &quot;Arguments are of the wrong type, are out of ac Read More

Views

16

Votes

0

Answers

10

August 15, 2011

date codes

Hi all! I have a question related to a date problem I&#39;m pulling out from a database. I would like to set the date &#160;to show once when &#160;a class schedule is only one day. And to show the st Read More

Views

5

Votes

0

Answers

8

August 15, 2011

Error with Null Date

I have a ASP form in which one can edit a record that was previously entered into a database. &#160;The problem is that a date field - DateRvdWithLAA - &#160;may remain empty/null. &#160;If the field Read More

Views

54

Votes

0

Answers

19

August 15, 2011

Problem with Events Calendar - ASP Classic

I&#39;m trying to modify a events calendar I found online. The calendar works fine, but I want to modify the code to highlight the day that has events versus showing the actual event title/description Read More

Views

18

Votes

0

Answers

8

August 15, 2011

Problem passing empty date form fields from asp page to Foxpro 6.0

I am not a Foxpro 6.0 expert and am having a problem with empty date fields. &#160;I cannot force entry, only use isdate() to see if its a valid date. &#160;If the user skips the fields altogether, ho Read More

Views

20

Votes

0

Answers

5

August 15, 2011

ASP page takes too long to display

I have a page that display a listing of files. It is very standard: SQL select statement creates a record set, do/while loop goes through each record and displays the results via ASP on a web page. Th Read More

Views

11

Votes

0

Answers

11

August 15, 2011

ASP with MySQL addnew problem

Hi experts, please see where did i make a mistake, why this code wont work for me: &lt;!--#include file=&quot;db_inc.asp&quot;--&gt; &lt;% Dim objCon, strDbCon, objRs, strSQL Set objCon = Server.Creat Read More

Views

9

Votes

0

Answers

7

August 15, 2011

How Do I Auto Populate An Text Field With Text From Another Field?

I am attempting to modify a page on our internal website (written in ASP). &#160;Right now the user enters information into the field for &quot;user name:&quot;, then enters the email address in the & Read More

Views

25

Votes

0

Answers

7

August 15, 2011

Drop down menu display selected value and show the rest of the values in the recordset

Experts, I have an asp page with a form and table on it. &#160;When a user clicks a link that is displayed for each record in the table they are taken to a page that allows them to edit the informatio Read More

Views

16

Votes

0

Answers

21

August 15, 2011

How can I get checkboxes to show up in an ASP form page?

I have created an ASP form that sends recordsets to an MS Access database. Included in the records are several checked boxes. When the user calls up an update page, I want them to be able to see the c Read More

Views

24

Votes

0

Answers

34

August 15, 2011

Problem with comparevalidator/ text box change

I am using asp 2.0 My html form has 2 text boxes txtReportStartDate and txtReportEndDate It also contains the following compare validator &#160;&lt;asp:CompareValidator &#160; &#160; &#160; &#160; &#1 Read More

Views

14

Votes

0

Answers

1

August 15, 2011

Help with reading a recordset into variable object names for fdf and pdf output

I have created an ASP page to pull information from a recordset into the FDF toolkit to display a pre-filled pdf form to the end user. &#160;I have created the pdf and have lots of form fields that ne Read More

Views

19

Votes

0

Answers

3

August 15, 2011

enter records to a join table in access through asp

Hello, I am a Novice ASP programmer, so any answer will be greatly appreciated. I have an MS Access database that consists of 2 tables (tbl_Book and tbl_Category). The relationship is many-to-many. Th Read More

Views

10

Votes

0

Answers

5

August 15, 2011

about oracle database working with asp

i have aproblem that i design an asp working with oracle database, and i use oo4o to connect the vbscript code to the database ,and i have atable that contain afield called (record_date),when i try to Read More

Views

17

Votes

0

Answers

6

August 15, 2011

How to send date across network and read it with ASP to web browser?

I&#39;m kind of just looking for advice on this one. &#160;Here&#39;s the problem: There is a batch file that copies files from one computer across a network to a webserver. &#160;These files are some Read More

Views

4

Votes

0

Answers

4

August 15, 2011

Whats wrong with my code? converting VB asp to C#.NET (html problem?)

Dear Experts, This is my third post today!! I&#39;m converting vb asp to C#.NET, I took the 2 files (header and footer) which were used in the asp site and tried to copy the code into the right places Read More

Views

49

Votes

0

Answers

15

August 15, 2011

Help with this SQL Query in ADO

I work for a retail chain and my current project involves allowing the stores to access their data (customer transactions, number of customers who enter the store, etc) through an asp page. It works p Read More

Views

26

Votes

0

Answers

10

August 15, 2011

Date Format Not Binding To GridView

I am having a problem binding the correct date format to my grid view. I am getting the dates like this: newRow(&quot;Term&quot;) = dtColData.Rows(0)(&quot;TERMDTE &quot;).ToStrin g() where dtColData Read More

Views

24

Votes

0

Answers

14

August 15, 2011

Cookies Problem

I have an ASP file called testcookie.asp that contents this small script: &lt;% response.cookies (&quot;MyCookie&quot;)(&quot;MyValue&quot;) = 99 response.cookies (&quot;MyCookie&quot;).expires = DATE Read More

Views

10

Votes

0

Answers

4

August 15, 2011