Link to home
Start Free TrialLog in
Avatar of evci
evci

asked on

C# Adjust DateTime based on Input Parameter

Hi ... need your help with a DateTime issue.  I have a script that runs via a job scheduler. When the 'job' kicks off, it passes the appropriate DateTime (it is not always NOW.  The script runs 24 hours a day at the top of the hour.  Sometimes a job is delayed by 15 minutes to 45 minutes, but will always use the top of the hour time).

The DateTime are passed automatically to my script via @@startDateTime@@ and @@endDateTime@@.  The format of these two parameters are "yyyy-MM-dd 00:00".

Assume
     @@startDateTime@@ = "2016-02-10 10:00"
    @@endDateTime@@ = "2016-02-10 10:59"

I need to return newStartDateTime = "2016-02-10 09:00" and newEndDateTime = "2016-02-10 09:59"
Avatar of dinesh manikkam
dinesh manikkam

Are you trying to minus an hour in your C# code?
Avatar of evci

ASKER

Yes. I need to minus an hour.
Hi,

Here it is.
newStartDateTime = dt.AddHours(-1);
newEndDateTime = dt.AddHours(-1);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of evci

ASKER

Thanks for the help.  Worked.