if Date1 > Date2 question

  • Автор темы Автор темы PHaRTnONu
  • Дата начала Дата начала

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Реакции
48
Баллы
28
So to start, im feeling right dumb i am 99% sure I've done this in the past with out issue

I need to make a logic decision on a action if One date is larger then the previous date

EG: is date 1 in the future or past.

And i can not remember how it was done.
I did look in the forums with out much luck
(maybe convert to unix epoch time coding?)

:dy:

A easy solution would be much appreciated
(current format is MMMM dd, YYYY
 
1.png

2.png

3.png
 

Вложения

  • 1667548910112.png
    1667548910112.png
    12 KB · Просмотры: 132
  • 1667548971641.png
    1667548971641.png
    7 KB · Просмотры: 139
Actually I had
Код:
Развернуть Свернуть Копировать
{-TimeNow.Date MMMM dd, yyyy-} < {-Variable.ReleaseDate1-}
Which still gives the slightly different error but it looks perfect in the logic/return
(will always return false, unless the month is the same then it will give correct information)

99198
 
convert the time to unixtime (this is seconds) and it will be much easier to work with them

time now in unixtime
C#:
Развернуть Свернуть Копировать
int unixTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
return unixTime;

converting human time to unixtime
C#:
Развернуть Свернуть Копировать
var datestr = project.Variables["time_in_human"].Value; /// переменная с вашей датой
DateTime date = Convert.ToDateTime(datestr);
int unix = (Int32)(date.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
return unix;
 
  • Спасибо
Реакции: paydot
im still stuck with this MMMM dd, YYYY format
 
convert the time to unixtime (this is seconds) and it will be much easier to work with them

time now in unixtime
C#:
Развернуть Свернуть Копировать
int unixTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
return unixTime;

converting human time to unixtime
C#:
Развернуть Свернуть Копировать
var datestr = project.Variables["time_in_human"].Value; /// переменная с вашей датой
DateTime date = Convert.ToDateTime(datestr);
int unix = (Int32)(date.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
return unix;
99216

I was able to get it eventually.
So thank you
C#:
Развернуть Свернуть Копировать
var datestr = DateTime.ParseExact(project.Variables["ReleaseDate1"].Value, "MMMM dd, yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime date = Convert.ToDateTime(datestr);
int unix = (Int32)(date.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
return unix;

This will help me alot (wanted to make sure i left the code incase any one needs to convert Dates the C# conversion DateTime.ParseExact is defiantly helpful
 
(couldnt edit, but if you have issue's you can make if case's so if you dont have dd you do d, or if you dont have the days at all remove the dd altogether, same for the month (if you only had the year) it would be yyyy in the "" )

i put like 5 if case scenarios in there but you get the jist (plus i dont have the editor open so dont ahve the code off hand but wanted to leave the information incase any one need's this in the future
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)