Results 1 to 6 of 6

Thread: Foolproof function for dates in dd/mm/yy format?

  1. #1

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

    Angry Foolproof function for dates in dd/mm/yy format?

    Anyone know how to fix the date problem. It keeps swapping to mm/dd/yy. I need dd/mm/yy

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

  2. #2

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

    Cool This is what I have done which sometimes worjks

    xDate = Day(myDate) & "/" & Month(myDate) & "/" & Year(myDate)
    xdate= formatdatetime(xdate,1)


    Then the date is stored as 10 July 2001 and not 10/07/01 which means the month and day cant be mixed up.

    But when I put my project on a server running NT (I use PWS and win 98 at home) it game me an error in the SQL query. It didnt like having the date in that formate with the hashes ...i.e.
    #10 July 2001#

    so any ideas on how to fix my way or a totally new foolproof way. There must be some way of sorting it all out.
    You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!

  3. #3
    donW
    Guest
    the day/month format depends on the Windows setting, hence different on different machines!
    I use only :
    mydatestring = format(now("dd/mm/yyyy")

    or one of the many " " options. (check out help: format, user defined options)

    this always gives you a string as you expect it

  4. #4
    MarcelB
    Guest
    So it could be just me, but I thought VBScript doesn't support the format function, but only the formatdatetime function?

  5. #5
    donW
    Guest
    yes format is in VB6 . dont know about vbscript.

  6. #6
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Create function to convert your date :

    Code:
    Dim strDay, strMonth, strYear
    Dim strDate
    
    strDay = Day(Now)
    If len(strDay) < 2 Then strDay = "0" & strDay
    strMonth= Month(Now)
    If len(strMonth) < 2 Then strMonth= "0" & strDay
    strYear = Year(now)
    
    strDate = strDay & "/" & strMonth & "/" & stryear
    Hope it helps !
    Regards,

    El-Nino

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