This topic is locked

DateAdd problem (Not writing days/months proper) with Regional British

2/3/2010 7:36:26 PM
ASPRunnerPro General questions
M
Maurits author

Hi Admin
I have a problem.

If i create a project with Regional setting English(British)the date should be: 03/02/2010 10:57:01 PM (3rd March 2010)
I was just testing a few things on the demo account in a table to see how the date will be written down, also how many days are between two dates, and add 6 months to a date.
For example i was calculating some days between some dates like:
BeforeAdd:
Dict("TransactionReference") = DateDiff("d", Now, "28/02/2010")

Result: 25 is written down in the database, perfect!!
PROBLEM:

BeforeAdd:

Dict("TransactionReference") = DateAdd("d", +12, Now())

Result: 2/15/2010 10:57:01 PM
If i use to add 6 months:

Dict("TransactionReference") = DateAdd("m", +6, Now())

Results: 8/3/2010 11:01:24 PM
Also i tries to add 6 years to the Now()

Dict("TransactionReference") = DateAdd("yyyy", +6, Now())

Result: 2/3/2016 11:09:48 PM
In all cases it is reading the right day, month and year, but it is written like the US-setting.

Reading correclty dd/mm/yyyy but written wrongly mm/dd/yyyy
I have tried this:
Dim tmpDate as Date

tmpDate = DateAdd("m", +6, Now())

Dict("TransactionReference") = Format(tmpDate,"dd/mm/yyyy")
But i do get an error as it is trying to write a mixed up UK-US date format into the tmpDate
Please help...
Many thanks,
Maurits

Sergey Kornilov admin 2/4/2010

As a first step - try to print result of DateAdd on the web page instead of assigning it to variable.
You can also try ASPRunnerPro 6.1 or 6.2 to see if it works as expected there.

M
Maurits author 2/4/2010



As a first step - try to print result of DateAdd on the web page instead of assigning it to variable.
You can also try ASPRunnerPro 6.1 or 6.2 to see if it works as expected there.


Thanks anyway Admin, it was printing it on the web page ok.
As it was a late night trying to sort it, next day, i just saw that i forgot something stupid.
When assigning it to a text field you have to use Cstr.
AddMonth = Cstr(CDate(DateAdd("m", +1, Date())))

TotalDaysThisMonth = DateDiff("d", Now, "28/02/2010")
Dict("TransactionReference") = AddMonth & " : " & TotalDaysThisMonth
Cheers