SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Playing with dates in SQLite
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

avinash.natekar
Starting Member

5 Posts

Posted - 10/11/2012 :  08:00:46  Show Profile  Reply with Quote
My Table has timestamp in 'MM\DD\YYYY HH:MM:SS' format but its varchar. How can I get last 7 days data. I know in SQL Server its easy but not able to acheive this in SQLite
Could you guys help out here ?

Avinash
-QA(Automation)

bandi
Flowing Fount of Yak Knowledge

India
2218 Posts

Posted - 10/11/2012 :  08:56:30  Show Profile  Reply with Quote
Check this link, You can able to get solution

http://www.sqlite.org/lang_datefunc.html


SELECT * FROM myTable WHERE DATE(timeStamp) >= DATE('now', 'weekday 0', '-7 days');

--
Chandu
Go to Top of Page

avinash.natekar
Starting Member

5 Posts

Posted - 10/16/2012 :  07:48:23  Show Profile  Reply with Quote
Hey bandi , what I missed is timestamp format is MM\DD\YYYY HH:MM:SS AM\PM' format which is not supported as timestring in the sqlite datetime functions

Avinash
-QA(Automation)
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2218 Posts

Posted - 10/16/2012 :  08:04:07  Show Profile  Reply with Quote
quote:
Originally posted by avinash.natekar

Hey bandi , what I missed is timestamp format is MM\DD\YYYY HH:MM:SS AM\PM' format which is not supported as timestring in the sqlite datetime functions

Avinash
-QA(Automation)



Then use REPLACE('MM\DD\YYYY HH:MM:SS', '\', '-') function to get supported format...

Check these links:
http://www.somacon.com/p370.php
http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions


--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000