将前导零填充到固定长度的固定数字 [英] Padding a fixed number with leading zeros upto a fixed length

查看:87
本文介绍了将前导零填充到固定长度的固定数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用VS2010的水晶报告.我正在尝试为以下情况创建公式:

x =任何数字(固定的8位数字,不能小于或大于)

如果X的长度小于8,则在其前面填充所需量的0's以使其长度为8.结果也应该是数字而不是字符串.

例如:

X = 123
公式的结果应为00000123

X = 9
公式的结果应为00000009
任何帮助将不胜感激.在此先感谢.

Crystal report using VS2010. I am trying a to create a formula for the following scenario:

x = any number (Fixed number of 8 digits, cant be less or greater)

If Length of X is less than 8, pad the required amount of 0''s in the front to make its length 8. Result should also be a number and not a string.

Eg:

X = 123
Result of Formula should be 00000123

X = 9
Result of Formula should be 00000009
Any help will be appreciated. Thanks in advance.

推荐答案

我明白了

右("0000"&{MyFieldToPad},8)

可以按我的要求完美地工作.
I got it

Right("0000"&{MyFieldToPad},8)

Works perfectly as I want it to.


这篇关于将前导零填充到固定长度的固定数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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