#1
  1. No Profile Picture
    matt1174
    Guest
    Devshed Newbie (0 - 499 posts)

    Date Format help please


    Hi all

    I need some help formatting a date entry which I'm using as a reference number - I shall explain.

    On my database I need to give each entry an unique reference number, and rather than just go with the standard autonumber I'm using a combination of the date the entry is made in the combination yyyyddmm plus the autonumber (in a three digit format), so there will be, ideally an 11 digit reference number which goes (for today) 20112007041.

    The problem I'm having is in my "reference number" table entry, the default value is down as "Year(Date()) & Day(Date()) & Month(Date())", which gives me my date related reference number, however I need all the dates/numbers displayed to be in two digits, ie preceeded by a zero if a single digit day or month as currently they are not, coming out 2011207041.

    Can anyone help me with this please (if it makes sense?)

    Thanks
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,207
    Rep Power
    4279
    use FORMAT(DATE(),"YYMMDD")
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    matt1174
    Guest
    Devshed Newbie (0 - 499 posts)
    Many Thanks - works a treat

IMN logo majestic logo threadwatch logo seochat tools logo