if Date1 > Date2 question

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
 

volody00

Client
Регистрация
06.09.2016
Сообщения
918
Благодарностей
953
Баллы
93

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
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
 

backoff

Client
Регистрация
20.04.2015
Сообщения
6 052
Благодарностей
6 481
Баллы
113
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

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
im still stuck with this MMMM dd, YYYY format
 

backoff

Client
Регистрация
20.04.2015
Сообщения
6 052
Благодарностей
6 481
Баллы
113

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
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
 

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
(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
 

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