Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:43:00+00:00 2026-06-05T04:43:00+00:00

I live in Iran and we here in Iran use Solar dates instead of

  • 0

I live in Iran and we here in Iran use Solar dates instead of the Gregorian dates. Is it possible to change Date datatype from Gregorian date to Solar date. Also, I want to use the date function such as DateAdd() , DateDiff() , .. in my query.

EDIT :

Months desciption in solar date:

1-  31 day
2-  31 day
3-  31 day
4-  31 day
5-  31 day
6-  31 day
7-  30 day
8-  30 day
9-  30 day
10- 30 day
11- 30 day
12- 29 day (in Leap year 30 day)
SUM-365 day in each year

and start of solar date is 23-3-… of each Gregorian date.

EDIT 1

I use below function in SQL Server for convert gregorian date to solar date:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[PersianDate]
(@MiladiDate DATE)
returns varchar(10)
AS
BEGIN
    Declare @days int
    Declare @year int
    set @year=Year(@MiladiDate) 
    Declare @month int  
    Set @days=DATEDIFF ( day ,  Convert(Date,cast(Year(@MiladiDate) as varchar)+'/1/1'), @MiladiDate)+1
    if @days>79  --یعنی یک فروردین ماه
    begin
        set @days=@days-79
        if @days<=186
        begin
            set @month=@days/31;
            if (@days%31=0)
                set @days=31
            else
            begin
                set @month=@month+1
                set @days=@days%31
            end
        end
        else
        begin
            set @days=@days-186
            set @month=6+@days/30;
            if (@days%30=0)
                set @days=30
            else
            begin
                set @month=@month+1
                set @days=@days%30
            end
        end
        set @year=@Year-621
    end
    else
    begin
        set @year=@year-1   
        if (((@Year % 100)<> 0 and (@Year % 4) = 0) or ((@Year % 100)= 0 and (@Year % 400) = 0))
            set @days=@days+11
        else
            set @days=@days+10
        set @month=@days/30+9
        if (@days%30=0)
            set @days=30
        else
        begin
            set @month=@month+1
            set @days=@days%30
        end
        set @year=@year-621
    end
    RETURN cast (@year as varchar)+'/'+ 
                                    case
                                    when @month<10 then '0'
                                    else ''
                                    END
                                    + cast (@month as varchar)+'/'+
                                    case 
                                    when @days<10 then '0'
                                    else ''
                                    END
                                    + cast (@days as varchar)
END

EDIT 2

For convert solar date to gregorian date can use CLR function:

Create CLR Function

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:43:02+00:00Added an answer on June 5, 2026 at 4:43 am

    You cannot change the Date datatype calender from gregorian to solar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Live example here: http://timkjaerlange.com/foobar/stack-stuff/august-18-2010/test.html I want to animate addClass and removeClass on this interface
So I have a live video from a web camera. I want to stream
Live streaming video in html 5 - what is required from server to stream
I have a live database that had some data deleted from it and I
I have a live db that has some 2011 dates that were entered as
Live demo: http://jsfiddle.net/9Y7Cm/1/ I want the text to be placed at the 50% of
Live Example Here Press any of buttons. Can you see shaky slideDown effect? In
SEE LIVE MENU HERE. I am trying to figure out why the drop-down disappears
Live Chat is a very famous tool on websites, and the operators use a
Hi there's a live version of the code below (taken from a tutorial) at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.