Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating record toggles between DD/MM/YYYY and MM/DD/YYYY

Status
Not open for further replies.

kevpho

Programmer
Jun 9, 2003
47
CA
hi,

for some reason, whenever i am updating one of my records, it switches the date format from DD/MM/YYYY to MM/DD/YYYY or vice versa, depending on what it is originally. Here's the code (dbConnection has already been opened):

Code:
strSQL = "UPDATE WorkOrders SET Completed=True," 
strSQL = strSQL & "DateCompleted=" & "#" & request.form("DateCompleted") & "#"
strSQL = strSQL & " WHERE ID=" & request.form("ID_Value")

Set updateWR = dbConnection.Execute(strSQL)
Set updateWR = Nothing

The thing about the date is it's not even being changed, it's just a hidden value on a form that's being passed ... not sure why it's doing this .. it's screwing up my results tables which are sorted by date .. any ideas ? thanks

kevin
 
type of DB and Date/Time format stated in the design of the fields?

_____________________________________________________________________
onpnt2.gif

[bdaycandle]
 
sorry forgot about that ... it's an Access DB and the dates are in Short Date format
 
intersting. from memory the shortdate is mm/dd/yy in access to that leads me to believe 1) you're getting the date fromt he client and it is formatted dd/mm/yy and or IIS is set up to the dd/mm/yy format

have you checked these possibilities yet?

_____________________________________________________________________
onpnt2.gif

[bdaycandle]
 
i'm getting the date from the server i'm sure of that cause it would just be something like this:

<input type=&quot;hidden&quot; value=&quot;<%=Date%>&quot; name=&quot;DateRequested&quot;>

now as for the IIS thing i'm not totally sure how to test for that ... would i have to get the server administrator to look at that ? ... now it's odd that it would keep toggling though ...
 
just do a

Response.Write Date()

or check my FAQ on formatting dates in this forum and set the format in the start of the script with the LCID and just be done with it. :)

_____________________________________________________________________
onpnt2.gif

[bdaycandle]
 
well doing a response.date gave me 12/08/2003 meaning it's DD/MM/YYYY

i tried a bunch of the different LCID's but none of them even change the date format EXCEPT for French Canada ... which gave me YYYY-MM-DD

i am positive that about a week ago the settings were on MM/DD/YYYY ... maybe my server admin's just playing around w/ me
 
I would set the fail safe function in the script then seeing as it sounds you do not have control over the server
eg:
Function MyDate()
dteCurrent = Date()

dteDay = Day(dteCurrent)
dteMonth = Month(dteCurrent)
dteYear = Year(dteCurrent)

MyDate = dteMonth & &quot;/&quot; & dteDay & &quot;/&quot; & dteYear
End Function




_____________________________________________________________________
onpnt2.gif

[bdaycandle]
 
ugh that sucks ... but i guess it's gonna have to be the way to do it ... thanks for your help

kevin
 
no need to use a function

just the line:
myDate = Month(now) & &quot;/&quot; & Day(now) & &quot;/&quot; & Year(now)
or:
myDate = Day(now) & &quot;/&quot; & Month(now) & &quot;/&quot; & Year(now)

obviously for which ever way you want it :)

I can't be bothered to have a sig!
 
yeah, I guess I'm feeling the age and that thing when I was starting out getting drilled to do things structured and in a way myself and my followers of unfortunate souls that had to maintain my scripts later down the line would be left with a head full of hair with a easy to maintain and debug mess of code. [wink]

_____________________________________________________________________
onpnt2.gif

[bdaycandle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top