Results 1 to 2 of 2

Thread: Gurus - how to do date manipulation with datetime data

  1. #1
    wo Guest

    Gurus - how to do date manipulation with datetime data

    Hello,

    I'm trying to use SQL for data warehousing using dates for manipulating data. As SQL doesnt have date, just timedate, and if I want to compare 2 dates to obtain someones age ( ie date - date of birth = age ) I have to use a TIMEDIFF or equivelent. This is REALLY annoying. Is there anyway to use just dates without having to code extra?

    Does SQL ignore the time part of a datetime column - ie can I just do a date manipulation without concerning myself with the time ( assuming the time is NOT default at 00:00:00 for every entry ) or am I stuck with treating the field as a complete datetime? It may seem a dumbass question, but as I have to do a lot of date manipulations, it is essential to know.

    Many thanks,

    Warwick.


  2. #2
    Mukund Joshi Guest

    Gurus - how to do date manipulation with datetime data (reply)

    Hi,
    Refer the help on Convert in Books Online, by using the desired style value you can convert a datetime field in to any date format and compare it.
    For e.g.

    select convert(varchar(10),column_name, 101) from table_name
    Here column_name is the name of your datetime column.

    This will return you the Date in USA format. Generally for comparison purpose you can use the ANSI or ISO format.

    Hope this helps.

    Mukund.
    (j.mukund@zensar.com)

    ------------
    wo at 3/13/01 6:51:16 PM

    Hello,

    I'm trying to use SQL for data warehousing using dates for manipulating data. As SQL doesnt have date, just timedate, and if I want to compare 2 dates to obtain someones age ( ie date - date of birth = age ) I have to use a TIMEDIFF or equivelent. This is REALLY annoying. Is there anyway to use just dates without having to code extra?

    Does SQL ignore the time part of a datetime column - ie can I just do a date manipulation without concerning myself with the time ( assuming the time is NOT default at 00:00:00 for every entry ) or am I stuck with treating the field as a complete datetime? It may seem a dumbass question, but as I have to do a lot of date manipulations, it is essential to know.

    Many thanks,

    Warwick.


Posting Permissions

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