SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Selecting something where date is less than a date?

    I want to select a value where the field (session_user_last_updated) is less than a date...

    The field 'session_user_last_updated' is a VARCHAR but it's a date. I did that because I don't like the format mySQL stores dates, with the dashes.

    How can I do it?
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no reason not to like the mysql date storage because when you pull it you can always reformat it (if that is why you dislike it). And if you put the column as a date then you can use the mysql date and time functions.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    Vermicious Knid moncur's Avatar
    Join Date
    May 2003
    Location
    Salt Lake City, UT
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're storing the dates something like '20030516', you should be able to compare them numerically. You're still much better off using a Date field, though, and they're not stored with dashes.

  4. #4
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They look like 2002-7-03 or some such And using VB.NET it would be annoying to keep having to reformat it.
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,245
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    don't reformat mysql dates with an external program, reformat them with mysql's date_format() function

    change the field from varchar to date
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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