LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[CVI2015] Haw can I get an old date from the current date ?

Solved!
Go to solution

Hello, 

 

I'm getting the current system date. 

I need to get the last week date. So : 

if current date = 22/03/2018 => last week = 15/03/2018

if current date = 02/03/2018 => last week = 23/02/2018

if current date = 02/04/2018 => last week = 26/03/2018

etc.... 

 

Any ideas please ? 

Thanks ! 

0 Kudos
Message 1 of 5
(3,470 Views)

i suppose that you can use:

 

GetSystemDate (&month2, &day2, &year2);
sprintf (TimeBuffer, "%02i- %02i / %02i", day2+8, month2-1, year2);

 

or:

GetSystemDate (&month2, &day2, &year2);
sprintf (TimeBuffer, "%02i- %02i / %02i", day2+24, month2-1, year2);

0 Kudos
Message 2 of 5
(3,464 Views)
Solution
Accepted by topic author HoussamAz

I propose the use of "CVI Time" from the Utility Library:

 

t = GetCurrentCVIAbsoluteTime()

CVITimeIntervalFromTimeUnit (CVITimeUnitDays, 7, &i);

DecrementCVIAbsoluteTime (&t, i);

CVIAbsoluteTimeToLocalCalendar( ... );

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 3 of 5
(3,449 Views)

Hello venusnajad56, 

 

The main idea is to not be obliged to calculate the date .... otherwise, I have to implement many cases. 

I'm looking for something "automatic". 

0 Kudos
Message 4 of 5
(3,438 Views)

Hello CVI-User, 

 

It's the solution. Thank you. 

0 Kudos
Message 5 of 5
(3,436 Views)