donnie91910
asked on
Query Date/Time field
I need to query a table where I am looking at a time stamp. The time stamp that i will be looking for will be for the month of January 2013.
The dates in the time stamp will be formatted like this (Date/Time):
1/1/2013 2:00:00 PM
1/3/2013 4:00:00 PM
1/17/2013 8:00:00 PM
How do I query this field so that I only get the month of January and the year of 2013.
Thanks.
The dates in the time stamp will be formatted like this (Date/Time):
1/1/2013 2:00:00 PM
1/3/2013 4:00:00 PM
1/17/2013 8:00:00 PM
How do I query this field so that I only get the month of January and the year of 2013.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about:
Select Format(date_col, "mmmm yyyy")
That will give you January 2013
Select Format(date_col, "mmmm yyyy")
That will give you January 2013
mmm will give you Jan
mm will give you 01
ASKER
There are other dates also:
1/1/2013 2:00:00 PM
1/3/2013 4:00:00 PM
1/17/2013 8:00:00 PM
2/11/2009 4:00:00 PM
4/21/2010 6:00:00 PM
6/21/2005 1:00:00 PM
I only want to query for the January 2013 dates.
1/1/2013 2:00:00 PM
1/3/2013 4:00:00 PM
1/17/2013 8:00:00 PM
2/11/2009 4:00:00 PM
4/21/2010 6:00:00 PM
6/21/2005 1:00:00 PM
I only want to query for the January 2013 dates.
you mean to say you want all sates for JAn 2013 , does not want formatting
try this
Select date_col from tablename
where Month(date_col) = 1 and Year(date_col) = 2013
try this
Select date_col from tablename
where Month(date_col) = 1 and Year(date_col) = 2013
select * from table where Month ( coloumn name ) =01 and year (coloumn name) =2013
Check and update if it s working.
Check and update if it s working.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select to_char(<date_col>, 'mm/dd/yyyy hh:mi:ss AM') from <NameOfTable> where to_char(<date_col>, 'mmyyyy') = '012013';
[[date-field] between [low-date] and [high-date]
see: http://www.youtube.com/wat ch?v=TFXzG dTSfTg
note, generally in sql: "between ... and ..." is the equivalent of:
[date-field] >= [low-date] and [date-field] <= [high-date]
see: http://www.youtube.com/wat
note, generally in sql: "between ... and ..." is the equivalent of:
[date-field] >= [low-date] and [date-field] <= [high-date]
ASKER