Finding current weekday of the week using Server.Time

Created at 13 Sep 2014, 16:29
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FL

flannery

Joined 25.07.2014

Finding current weekday of the week using Server.Time
13 Sep 2014, 16:29


I've been working with some specific dates and times for an algorithm and now I need to know which weekday it is when the bot is running.

Currently I am using this:

string day_0 = Server.Time.AddDays(0).ToString("dd-MM-yyyy");

To find the date of the current day.

Is there a way to output the current weekday instead? eg. Monday, Tuesday or Wednesday and so on?

Best Regards

Flannery


@flannery
Replies

Balena
13 Sep 2014, 23:52

you can use/modify these...

 

          //if (Server.Time.DayOfWeek == DayOfWeek.Sunday && Server.Time > stopTime)
            //return;

            //if (Server.Time.DayOfWeek == DayOfWeek.Monday && Server.Time > stopTime)
            //return;

            //if (Server.Time.DayOfWeek == DayOfWeek.Tuesday && Server.Time > stopTime)
            //return;
            
            //if (Server.Time.DayOfWeek == DayOfWeek.Wednesday && Server.Time > stopTime)
            //return;

            //if (Server.Time.DayOfWeek == DayOfWeek.Thursday && Server.Time > stopTime)
            //return;        

            if (Server.Time.DayOfWeek == DayOfWeek.Friday && Server.Time > resetTime.AddSeconds(ySeconds))
                return;

            if (Server.Time.DayOfWeek == DayOfWeek.Saturday)
                return;


@Balena

Spotware
15 Sep 2014, 11:15

You can use the following code snippet to output current weekday:

Print(Server.Time.DayOfWeek);

 


@Spotware