Results 1 to 2 of 2

Thread: Date keeps swapping dd/mm/yy to mm/dd/yy

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    South Africa
    Posts
    113

    Angry Date keeps swapping dd/mm/yy to mm/dd/yy

    Hi there,
    I am making something with ASP and I need to capture the date of when a message is enterd and then sort all messages by date.

    Problem is that I need the Dates to be dd/mm/yy. The dates are only formastted like that when the day is larger than 12..i.e. if its 16/05/01 then its alright.
    But with 10 May 2001 I get
    05/10/01

    Please could soemone help me with how to get the date to format correctly. I have tried this...

    private sub AccDate(myDate) 'date converter
    theDate = Day(myDate) & "/" & Month(myDate) & "/" & Year(myDate)
    end sub

    the date is fine until it gets written to the access database and then it swaps to the wrong way around. My regional settings are set correctly.

    Thanks in advance
    You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!

  2. #2
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    What i find works well, is when you insert the record into the database, just use the date() function to insert the current date. then use this handy function to output the date any way you want:

    Code:
    FormatDateTime (Date, DateFormat) 
     
    The FormatDateTime function formats dates and times. 
     
    There is one mandatory argument. 
     
    Date 
     
    The Date argument is any valid date expression. 
     
    Code: 
    <% =FormatDateTime("6/26/1943") %> 
    <% =FormatDateTime("15:34") %> 
     
    Output: 
    6/26/43 
    3:34:00 PM 
     
    There is one optional argument. 
     
    DateFormat 
     
    The optional DateFormat argument must use the constant or value from the Date Format CONSTANTS. 
     
    CONSTANT VALUE DESCRIPTION 
    VBGeneralDate   0   Display the date and time using system settings 
    VBLongDate      1   Display the date in long date format 
    June 26, 1943 
    VBShortDate     2   Display the date in short date format 
    6/26/43 
    VBLongTime      3   Display the time in long time format 
    3:48:01 PM 
    VBShortTime     4   Display the time in short time format (24 hour clock) 
    15:48 
    
     
    Code: 
    <% =FormatDateTime("6/26/1943", 1) %> 
    <% =FormatDateTime("3:34:00 PM", 4) %> 
     
    Output:
    Saturday, June 26, 1943 
    15:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width