Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.259
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol 5.0.258
  HXTT DBF 7.1.260
  HXTT Excel 6.1.262
  HXTT Json 1.0.230
  HXTT Paradox 7.1.258
  HXTT PDF 2.0.258
  HXTT Text(CSV) 7.1.258
  HXTT Word 1.1.258
  HXTT XML 4.0.259
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT ACCESS
DATEDIFF (exp,exp) syntax
krishna
2010-12-16 22:06:23
Hi All,
Can i have the example sql statement about the DATEDIFF(exp,exp)?
i tried the follwowing command. but it is not worked.
select count(*) from scanAnalysis a where TRIM(a.patient_key) = ? and
date(a.scan_date)= date(?) or datediff(date(a.scan_date),date(?))<=5 and a.scan_type IN (6,7);

a.patient_key='1JTC04146R0883050'
date(?) =12/4/2005.


what is wrong in this query, Syntax error in expression getting.
Could you please provide mre the the sample query.

Thnaks,
Krishna

Re:DATEDIFF (exp,exp) syntax
HXTT Support
2010-12-16 22:45:10
If you're using PreparedStatement, you can use your sql, or datediff(date(a.scan_date),?)<=5 . You shouln't meet syntax error.

>date(?) =12/4/2005.
In sql, you need ' to enclose date string. For instance '2005-12-04'.

select date('12/4/2005');
will be detected and converted into select date('2005-12-04') .



Re:Re:DATEDIFF (exp,exp) syntax
saikrishna
2010-12-17 02:05:17
Hi,

i tried this sql statement. it is working and giving the result.

SELECT a.patient_key, a.scan_date, datediff("d",a.scan_date,6/28/2010)>=5 FROM ScanAnalysis a where a.patient_key in ('1JTC04146R0883050','1JU40912IO0583050');

but if i give this statement , it is not working.

SELECT a.patient_key, a.scan_date, datediff(date(a.scan_date),6/28/2010)<=5 FROM ScanAnalysis a where a.patient_key in('1JTC04146R0883050','1JU40912IO0583050');

or

SELECT a.patient_key, a.scan_date, datediff("d",date(a.scan_date),6/28/2010)>=5 FROM ScanAnalysis a where a.patient_key in ('1JTC04146R0883050','1JU40912IO0583050');

What could be the reason?

Thanks,
Sai
Re:Re:Re:DATEDIFF (exp,exp) syntax
HXTT Support
2010-12-17 02:14:16
1.st 6/28/2010 will become 1.0660980810234541E-4 value, not a date value:(
You should use '6/28/2010' or '2010-06-28' or {d '2010-06-28'}.

2nd. DATEDIFF supports 2~3 parameter, but it means different format.
2 parameters will calculate only days.
DATEDIFF(expr,expr2): returns the number of days between the start date expr and the end date expr2. expr and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
3 parameters can calculate any part of date.
DATEADD(INTERVAL, expr, date), DATEDIFF (INTERVAL, date1, date2), DATEPART (INTERVAL, date) For instance, SELECT DateAdd('m', 3, date1) FROM test;





Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap