format

SQLServerでもfromatと以前UPしましたが
馴れているVBAのformatとは大分違っている事に気がつく
今日2017/10/27の日付で
select format(getdate(),’D’) 2017年10月27日
select format(getdate(),’d’) 2017/10/27
select format(getdate(),’m’) 10月27日
select format(getdate(),’M’) 10月27日
select format(getdate(),’y’) 2017年10月
select format(getdate(),’Y’) 2017年10月
select format(getdate(),’DD’) DD
select format(getdate(),’dd’) 27
select format(getdate(),’MM’) 10
select format(getdate(),’mm’) 40(現在時の分)
select format(getdate(),’YY’) YY
select format(getdate(),’yy’) 17
select format(getdate(),’yy/mm/dd’) 17/01/27 01は現在時刻の分
select format(getdate(),’yy/MM/dd’) 17/10/27

最後のはどうにも変
VBAではどうかというと
debug.Print format(now,”D”) 27
debug.Print format(now,”d”) 27
debug.Print format(now,”m”) 10
debug.Print format(now,”M”) 10
debug.Print format(now,”Y”) 300 300はなんだかわからない
debug.Print format(now,”y”) 300
debug.Print format(now,”DD”) 27
debug.Print format(now,”dd”) 27
debug.Print format(now,”mm”) 10
debug.Print format(now,”MM”) 10
debug.Print format(now,”yy”) 17
debug.Print format(now,”YY”) 17
debug.Print format(now,”yy/mm/dd”) 17/10/27
debug.Print format(now,”yy/MM/dd”) 17/10/27

かなり違う
ではVBAで分はというとn
select format(getdate(),’MM’) = debug.Print format(now,”nn”)

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です