格式化日期格式 [英] Format Date in SPECIFIC STYLE

查看:117
本文介绍了格式化日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在开发一种能够为用户生成证书的软件。使用:



VB.NET 2008 w / Crystal Reports&MySQL 5.0



我的要求之一,在印刷证书上,它应该有一个特殊日期,格式如下:



格式:2013年1月24日至2013年1月24日

来自格式:2013年3月2日至2013年3月2日

来自格式:2013年1月3日至第3天2013年1月



你知道如何格式化日期,甚至在MySQL中显示这些东西吗?





即使在自定义日期格式下,我也没有在'格式对象下看到水晶报告中的任何选项。



但我看到其他.exe软件能以某种方式与我的要求类似

Hi,

I am developing a software that will generate certificates for the users. Using:

VB.NET 2008 w/Crystal Reports & MySQL 5.0

One of my requirements, on the printed certificate it should have a SPECIAL DATE with a format like below:

FROM FORMAT: "01/24/2013" TO "24th Day of January, 2013"
FROM FORMAT: "03/2/2013" TO "2nd Day of March, 2013"
FROM FORMAT: "01/3/2013" TO "3rd Day of January, 2013"

Do you know how to format date even in MySQL to show something these?


I didn't see any options from crystal report under 'FORMAT OBJECTS even in custom date format.

But i saw other .exe software that somehow able to do similar to my requirement

推荐答案

使用MySQL格式化



DATE_FORMAT( '2013-01-24','%D%M%,%Y)





样品查询



SELECT DATE_FORMAT(ColumnDate,'%D日%M,%Y)来自MySQL_TABLE
Format using MySQL

DATE_FORMAT('2013-01-24', '%D Day of %M, %Y)


Sample Query

SELECT DATE_FORMAT(ColumnDate, '%D Day of %M, %Y) FROM MySQL_TABLE


使客户可以使用值进行验证并对其进行格式化
make a custome veriable with the value and format it


在水晶报表中创建客户函数名称测试,从下拉菜单中选择基本语法。

creat a custome function name test in crystal report, select "Basic Syntax" from drop down.
Function test (t as date) as string
dim outString as string

if day(t)=1 then 
    outString="1st day of "
else 
    if day(t)=2 then 
        outString="2nd day of "
    else 
        if day(t)=3 then 
            outString="3rd day of "
        else 
            if day(t)=4 then 
                outString="4th day of "
            else 
                if day(t)=5 then 
                    outString="5th day of "
                End if
            end if
        end if
    end if
end if

if month(t)=1 then 
    outString=outString + "January, " + Replace (ToText (year(t),0),"," ,"" )
else 
    if month(t)=2 then 
        outString=outString + "February, " +    Replace (ToText (year(t),0),"," ,"" )
    else 
        if month(t)=3 then 
            outString=outString + "March, " +   Replace (ToText (year(t),0),"," ,"" )
        else 
            if month(t)=4 then 
                outString=outString + "April, " +    Replace (ToText (year(t),0),"," ,"" )
            else 
                if month(t)=5 then 
                    outString=outString + "May, " +    Replace (ToText (year(t),0),"," ,"" )
                End if
            end if
        end if
    end if
end if

    test =outString
End Function





从新的公式字段调用此函数。



call this function from new formula fields.

Formula=test(CDate ({Command.Work_date}))





将公式字段放入报告详细信息部分。



put the formula field into report details section.


这篇关于格式化日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆