diogom Posted May 24, 2013 at 08:39 AM Report #508700 Posted May 24, 2013 at 08:39 AM Olá, Como faço para comparar duas datas. string ola=datatime.now.tostring(dd/mm/yyyy) string ola2=22/05/2013; if(ola2<ola) { } else { } como não posso comparar duas strings, dame erro
pikax Posted May 24, 2013 at 08:54 AM Report #508701 Posted May 24, 2013 at 08:54 AM DateTime dt = DateTime.Now; DateTime dt2; if(!DateTime.TryParse("25/05/2013")) return;//nao deu certo a conversao if(dt<dt2) //... else //.... Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
nelsonr Posted May 24, 2013 at 08:54 AM Report #508703 Posted May 24, 2013 at 08:54 AM Podes usar algo assim if(DateTime.Now.Date==new DateTime(2013, 5, 22))
diogom Posted May 24, 2013 at 09:05 AM Author Report #508705 Posted May 24, 2013 at 09:05 AM Quero comparar uma data que é preenchida numa textbox e passada para uma variável e a data do sistema no formato dd/MM/yyyy
nelsonr Posted May 24, 2013 at 09:34 AM Report #508711 Posted May 24, 2013 at 09:34 AM O pikax já te deu um exemplo. Pode ser algo assim: DateTime dt; if(!DateTime.TryParse(TextBoxComAData.Text, out dt)) return;//nao deu certo a conversao if(dt<DateTime.Now.Date) //...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now