Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. comparing dates asp.net

comparing dates asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HowRU
    wrote on last edited by
    #1

    Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...

    M S I 3 Replies Last reply
    0
    • H HowRU

      Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. Just a suggestion - it looks like you're building client javascript code for the purpose of validation... if this is for an ASP.NET application, you may want to use a CompareValidator[^] control instead. The validator controls include a property EnableClientScript that governs whether or not they will output client-side javascript for validation.

      1 Reply Last reply
      0
      • H HowRU

        Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...

        S Offline
        S Offline
        Stephan Pilz
        wrote on last edited by
        #3

        Hello, I think you should convert the days, months and years to a number like this: strStartDay = Number (frm.txtStartDay.value); The comparision should now work! Greetings from Stephan

        1 Reply Last reply
        0
        • H HowRU

          Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...

          I Offline
          I Offline
          internetmouse
          wrote on last edited by
          #4

          you can use DateDiff Function in .NET assume we want to find the difference between two days Dim dattim1 As Date = #5/17/2004# Dim dattim2 As Date = #5/31/2004# Dim WD As Long = DateDiff(DateInterval.Day, dattim1, dattim2) WD Returned the numbers of diff. days between dattim1 and dattim2 and you can user validator controls to specify the format of date and others I.N.M(InterNetMouse)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups