Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Query Date/Time field

Posted on 2013-01-02
13
Medium Priority
?
367 Views
Last Modified: 2013-02-08
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.
0
Comment
Question by:donnie91910
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +3
13 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 1668 total points
ID: 38738969
which database you are using ?

SQL server

Select Month(date_col) , Year(date_col)
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 1668 total points
ID: 38738973
Oracle / PL SQL

SELECT EXTRACT(month FROM date_col) from table_name
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 1668 total points
ID: 38738975
Oracle / PL SQL

SELECT EXTRACT(month FROM date_col) , EXTRACT(year from date_col)  from table_name
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 1668 total points
ID: 38738980
mysql

Select Month(date_col) , Year(date_col)
0
 

Author Comment

by:donnie91910
ID: 38738982
Microsoft Access 2003 database .
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 1668 total points
ID: 38738991
same
Select Month(date_col) , Year(date_col)
http://www.techonthenet.com/access/functions/date/month.php
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38739007
How about:
Select Format(date_col, "mmmm yyyy")

That will give you January 2013
mmm will give you Jan
mm will give you 01
0
 

Author Comment

by:donnie91910
ID: 38739028
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.
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38739033
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
0
 

Expert Comment

by:santoshsahoo123
ID: 38739035
select * from table where Month ( coloumn name ) =01 and year (coloumn name) =2013

Check and update if it s working.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 332 total points
ID: 38739036
Select Format(date_col, "mmmm yyyy") From NameOfTable Where Format(date_col,"yyyy mm") = "2013 01"
0
 
LVL 5

Expert Comment

by:jaiminpsoni
ID: 38739766
select to_char(<date_col>, 'mm/dd/yyyy hh:mi:ss AM') from <NameOfTable> where to_char(<date_col>, 'mmyyyy') = '012013';
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 38842875
[[date-field] between [low-date] and [high-date]

see: http://www.youtube.com/watch?v=TFXzGdTSfTg

note, generally in sql: "between ... and ..." is the equivalent of:

[date-field] >= [low-date] and [date-field] <= [high-date]
0

Featured Post

Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question