Page 1 of 2

Change Login Date

PostPosted: Thu Apr 04, 2019 3:33 pm
by SBarnes
How do you change the login date in code so that any business objects will process / save at that date?

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 9:21 am
by Scott.Pearce
Code: Select all
Manager.Database.SysDateTime = CDate(NewLoginDate.ToShortDateString & " " & Manager.Database.SysDateTime.ToLongTimeString)

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 9:38 am
by SBarnes
Sorry I should have mentioned how to do it in c#

Re: Change Login Date  Topic is solved

PostPosted: Fri Apr 05, 2019 9:43 am
by Scott.Pearce
Code: Select all
Manager.Database.SysDateTime = (DateTime)NewLoginDate.ToShortDateString + " " + Manager.Database.SysDateTime.ToLongTimeString;


Mike insists we avoid mucking around with strings, so here are some further examples:

Code: Select all
Manager.Database.SysDateTime = DateTime.Now;

Code: Select all
Manager.Database.SysDateTime = DateTime.Now.AddDays(1);

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 9:44 am
by Mike.Sheen
Scott.Pearce wrote:Mike insists we avoid mucking around with strings


And don't you forget it!

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 9:48 am
by SBarnes
Thanks Scott but also sorry as I am with Mike on this one your further examples were a lot more intuitive than the strings.

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 10:06 am
by Scott.Pearce
Ironically, the first example is from our source code :-/

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 10:11 am
by SBarnes
Yes but it was also VB, still it could have been worse it could have been CIL :lol:

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 10:12 am
by Mike.Sheen
Scott.Pearce wrote:Ironically, the first example is from our source code :-/


Not anymore it isn't.
It's now:
Code: Select all
Manager.Database.SysDateTime = NewLoginDate.Date.Add(Manager.Database.SysDateTime.TimeOfDay)

Re: Change Login Date

PostPosted: Fri Apr 05, 2019 10:12 am
by Scott.Pearce
lol