compare TIMESTAMP

Posted By: Grat

compare TIMESTAMP - 02/02/21 09:00

FAQ: compare the time in format WDATE ... don't use!
Is better to know... laugh

Code
 //Wed 20-04-01 16:00 == unixtime 1585756800
 string GetTest(){
       return strf("%04d-%02d-%02d %02d:%02d", 2020,04,01,16,0);
}

// --------------------------- Main-----------------------------
function main() {
	string cTest;
	cTest = GetTest();
	var dwDate=wdatef("%Y-%m-%d %H:%M", cTest);	 
	printf("\ndwDate = %f",dwDate);
	
	cTest = strf("%d",utm(dwDate));
	printf("\n%s",cTest);

	var duDate=wdatef("%t",cTest);

	printf("\ndw: %f  du: %f",dwDate,duDate);
	printf("\nW: %d U: %d",utm(dwDate),utm(duDate));

	if (duDate == dwDate)
		printf("\nwdate is OK");
	if( utm(duDate) == utm(dwDate))
		printf("\nCompare with convert to UnixTime is OK");

}


output is:
Code

test compiling............... ok

dwDate = 43922.666667
1585756800
dw: 43922.666667  du: 43922.666667
W: 1585756800 U: 1585756800
Compare with convert to UnixTime is OK

Posted By: jcl

Re: compare TIMESTAMP - 02/03/21 16:26

Programmers never compare two vars with ==. Comparing them with > or < is ok.

https://manual.zorro-project.com/comparisions.htm
Posted By: TedMar

Re: compare TIMESTAMP - 02/08/21 15:08

if u use DATE as windows format , campare it as INT like me laugh

Code
  
ymd(wdate(0)) == 20210215





© 2024 lite-C Forums