logo
down
shadow

Validation of Month and Year


Validation of Month and Year

Content Index :

Validation of Month and Year
Tag : ruby-on-rails-4 , By : DicksGarage
Date : November 24 2020, 01:01 AM

help you fix your problem I'm using a custom validation to check if a card has expired (it has a month / year).
    def card_not_expired
      if exp_year.present? and (exp_year >= Time.now.year or 
        (exp_year == Time.now.year and exp_month >= Time.now.month))
        true
      end

      # Raise error for expired card
      errors.add(:exp_month, "can't be in the past")
    end

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Easiest way to show month number and year after certain month year upto current month and year


Tag : php , By : 小和尚
Date : March 29 2020, 07:55 AM
wish helps you you can use strtotime and date to do this.
$start=strtotime('2015-03-01');
while ($start <= time()){
    echo date('m/Y',$start) . "\n";
    $start=strtotime('+1 month', $start);
}
03/2015
04/2015
05/2015
06/2015
07/2015
08/2015
09/2015
10/2015
11/2015
12/2015
01/2016

C++ Month, day, and year validation


Tag : cpp , By : MP.
Date : March 29 2020, 07:55 AM
To fix this issue 1) There are a couple of issues here, but the most obvious one is in main():
int s=0; 
...
    checkDate(month, day, year);   // you don't store the status
    displayMessage(s);             // so s will always be 0 ! So good date !
    s=checkDate(month, day, year); // store the result of the check        
    displayMessage(s);             // and take it to display the message  
int checkDate(int month, int day, int year)
{
    int status=0; 

    if ((month == 1 || month == 3 || month == 5 || month == 7 ||
        month == 8 || month == 10 || month == 12) && ( day>31 || day<1) )
    {
        status = 3; 
    }
    else if ((month == 4 || month == 6 || month == 9 || month == 11) && (day>30 || day<1) )
    {
        status = 4; 
    }
    else if ((month == 2) && (year % 4 == 0) && (day>29 || day<1))
    {
        status = 5; 
    }
    else if ((month == 2) && (year % 4 != 0) && (day>28 || day<1) )
    {
        status = 6; 
    }
    else if ((year < 999) || (year > 10000))
    {
        status = 1;
    }
    if ((month < 1) || (month > 12))
    {
        status = 2;
    }
    return status;
};

How to dynamically retrieve all data from a year ago (Next Month) till the end of current Month based on year and month


Tag : sql , By : boonchew
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am using LEFT JOIN table calendar to bring months columns even if there is no data for some of the months. It works if I say tblCalendar.Year = 2016 so it will bring me all 12 month for current year. But I need data a year from the end of current month. So I am using data range
  WHERE   ( b.YearNum = YEAR(GETDATE())-1 and b.MonthNum >= MONTH(GETDATE())+1 ) OR 
          ( b.YearNum = YEAR(GETDATE()) and b.MonthNum <= MONTH(GETDATE()) )

How to get recent month, year(i.e March2017) and previous month, year(i.e February2017) and month number in two diffrent


Tag : sql-server , By : Yst
Date : March 29 2020, 07:55 AM
will help you How to get recent month, year(i.e March2017) and previous month, year(i.e February2017) and month number in two diffrent columns in sqlserver2013.
Select *
 From (values (Format(GetDate(),'MMMMyyyy'),DatePart(MONTH,GetDate()))
             ,(Format(DateAdd(Month,-1,GetDate()),'MMMMyyyy'),DatePart(MONTH,DateAdd(Month,-1,GetDate())))
             ) D([Month&Date],[Month No])
Month&Date      Month No
March2017       3
February2017    2

Crystal Reports: Display date range (month, first day of month, year to month, last day, year) based on field value


Tag : crystal-reports , By : Giles
Date : March 29 2020, 07:55 AM
should help you out You can achieve this with the following formulas.
Note the formula names, because they are partly dependent on each other.
DateAdd("m", -1, {@DOCDATE})
Date(Year({@prevMonth}), Month({@prevMonth}), 1)
Date(DateAdd("d", -1, Date(Year({@DOCDATE}), Month({@DOCDATE}), 1)))
CStr({@startDate}) & " to " & CStr({@endDate})
Related Posts Related QUESTIONS :
shadow
Privacy Policy - Terms - Contact Us © scrbit.com