asp.net - c# check date is weekend or weekday -


dayofweek today = datetime.today.dayofweek; if (today == dayofweek.sunday || today == dayofweek.saturday) {   clientscript.registerstartupscript(gettype(), "alert", "alert('" weekend"');", true); } else {     clientscript.registerstartupscript(gettype(), "alert", "alert('" weekday"');", true); } 

from line above able find if today weekend or weekday

now want date user input tried fail,

my text input format : 2016-10-04

string dateinput = datetextbox.text; dayofweek today = datetime.dateinput.dayofweek; 

use datetime.parseexact parse string datetime

string dateinput = datetextbox.text; //"2016-10-04" datetime dtresult = datetime.parseexact(dateinput, "yyyy-mm-dd", cultureinfo.invariantculture); dayofweek today = dtresult.dayofweek; 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

c# SetCompatibleTextRenderingDefault must be called before the first -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -